package com.chartHandle.excelService.service.impl;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.chartHandle.excelService.listen.WeeklySupplyStrategyDataListener;
import com.chartHandle.excelService.service.ReadWeeklySupplyStrategyService;
import com.projectCommon.bean.easyExcel.putTactics.WeeklySupplyStrategyData;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.io.ByteArrayInputStream;
import java.util.Map;

@Service
@Slf4j
public class ReadWeeklySupplyStrategyServiceImpl implements ReadWeeklySupplyStrategyService {
    @Override
    public WeeklySupplyStrategyData readSupplyStrategyData(byte[] fileByte, String fileName) {
        WeeklySupplyStrategyData weeklySupplyStrategyData = new WeeklySupplyStrategyData();
        weeklySupplyStrategyData.getNoteInformationMap().put("fileName", fileName);
        EasyExcel.read(new ByteArrayInputStream(fileByte), new WeeklySupplyStrategyDataListener(weeklySupplyStrategyData))
                .excelType(ExcelTypeEnum.XLS)
                .sheet("周货源投放策略")
                .headRowNumber(0)
                .doRead();
        return weeklySupplyStrategyData;
    }
}
